package com.jisucloud.clawler.regagent.service.impl.borrow;

import com.jisucloud.clawler.regagent.interfaces.PapaSpider;
import com.jisucloud.clawler.regagent.interfaces.PapaSpiderConfig;
import com.jisucloud.clawler.regagent.util.StringUtil;

import lombok.extern.slf4j.Slf4j;
import okhttp3.Request;
import okhttp3.Response;



import java.util.Map;


@Slf4j
@PapaSpiderConfig(
		home = "baicaif.com", 
		message = "白菜金融网是龙环普惠集团旗下的网络借贷信息中介平台,遵循 公平公正诚信透明的准则,为大众富裕阶层提供便捷的出借方式。", 
		platform = "baicaif", 
		platformName = "白菜金融", 
		tags = { "P2P", "借贷" }, 
		testTelephones = { "15985268904", "18212345678" })
public class BaiCaiJinRongSpider extends PapaSpider {

	public boolean checkTelephone(String account) {
		try {
			String url = "https://www.baicaif.com/login/checkPhone.do?phone=" + account;
			Request request = new Request.Builder().url(url)
					.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0")
					.addHeader("Host", "www.baicaif.com")
					.addHeader("Referer", "https://www.baicaif.com")
					.build();
			Response response = okHttpClient.newCall(request).execute();
			String res = StringUtil.unicodeToString(response.body().string());
			System.out.println(res);
			return res.contains("已存在");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean checkEmail(String account) {
		return false;
	}

	@Override
	public Map<String, String> getFields() {
		return null;
	}

}
